# One script to rule them all
# ... Uncomment as neccesary ...



###### Gop vs file size #####

# Remove audio from orignal videos (Ideally without transcoding)
# It is neccessary to transcode some of the videos in order to extract framestatistics - unfortunate.
# When transcoding, the target bitrate is matched to the original video with audio removed.
#ffmpeg -i vids/sintel.mp4 -y -an -vcodec mpeg4 -b 2500k vids/sintel_an.avi # Match video spec. best possible
#ffmpeg -i vids/bbb.avi -y -an -vcodec copy vids/bbb_an.avi # Ideal
#ffmpeg -i vids/ed.avi -y -an -vcodec copy vids/ed_an.avi # Ideal

## Make gopstats for original videos without audio track
#./gopstats.sh vids/sintel_an.avi data/sintel_an_gopstats.txt
#./gopstats.sh vids/bbb_an.avi data/bbb_an_gopstats.txt
#./gopstats.sh vids/ed_an.avi data/ed_an_gopstats.txt

## Make plot 1 based on originals_gopstat logs
./gop_vs_fsize.py data/sintel_an_gopstats.txt data/bbb_an_gopstats.txt data/ed_an_gopstats.txt

#############################







######## Unknown ##########

## Make framestats for original videos
#./framestats.sh vids/sintel_an.avi data/sintel_an_framestats.txt
#./framestats.sh vids/sintel_2_an.avi data/sintel_2_an_framestats.txt
#./framestats.sh vids/sintel_3_an.avi data/sintel_3_an_framestats.txt
#./framestats.sh vids/bbb_an.avi data/bbb_an_framestats.txt
#./framestats.sh vids/bbb_2_an.avi data/bbb_2_an_framestats.txt
#./framestats.sh vids/ed_an.avi data/ed_an_framestats.txt
##./framestats.sh vids/ed_2_an.avi data/ed_2_an_framestats.txt # Broken!


#############################














###### Prepare controlled vids ######

# Transcode controlled videos with GOP 20, variable bitrates
#ffmpeg -i vids/sintel.mp4 -y -an -vcodec mpeg4 -b 1500k -g 20 vids/sintel_an_G20_1500k.avi
#ffmpeg -i vids/sintel.mp4 -y -an -vcodec mpeg4 -b 2500k -g 20 vids/sintel_an_G20_2500k.avi
#ffmpeg -i vids/sintel.mp4 -y -an -vcodec mpeg4 -b 3500k -g 20 vids/sintel_an_G20_3500k.avi
#ffmpeg -i vids/bbb.avi -y -an -vcodec mpeg4 -b 1500k -g 20 vids/bbb_an_G20_1500k.avi
#ffmpeg -i vids/bbb.avi -y -an -vcodec mpeg4 -b 2500k -g 20 vids/bbb_an_G20_2500k.avi 
#ffmpeg -i vids/bbb.avi -y -an -vcodec mpeg4 -b 3500k -g 20 vids/bbb_an_G20_3500k.avi  
#ffmpeg -i vids/ed.avi -y -an -vcodec mpeg4 -b 1500k  -g 20 vids/ed_an_G20_1500k.avi
#ffmpeg -i vids/ed.avi -y -an -vcodec mpeg4 -b 2500k  -g 20 vids/ed_an_G20_2500k.avi 
#ffmpeg -i vids/ed.avi -y -an -vcodec mpeg4 -b 3500k  -g 20 vids/ed_an_G20_3500k.avi  

# Make framestats for controlled videos
#./framestats.sh vids/sintel_an_G20_1500k.avi data/sintel_an_G20_1500k_framestats.txt
#./framestats.sh vids/sintel_an_G20_2500k.avi data/sintel_an_G20_2500k_framestats.txt
#./framestats.sh vids/sintel_an_G20_3500k.avi data/sintel_an_G20_3500k_framestats.txt
#./framestats.sh vids/bbb_an_G20_1500k.avi data/bbb_an_G20_1500k_framestats.txt
#./framestats.sh vids/bbb_an_G20_2500k.avi data/bbb_an_G20_2500k_framestats.txt
#./framestats.sh vids/bbb_an_G20_3500k.avi data/bbb_an_G20_3500k_framestats.txt
#./framestats.sh vids/ed_an_G20_1500k.avi data/ed_an_G20_1500k_framestats.txt
#./framestats.sh vids/ed_an_G20_2500k.avi data/ed_an_G20_2500k_framestats.txt
#./framestats.sh vids/ed_an_G20_3500k.avi data/ed_an_G20_3500k_framestats.txt

# Make frame_log.txt for controlled videos
#./frame_log.py data/sintel_an_G20_1500k_framestats.txt data/sintel_an_G20_2500k_framestats.txt data/sintel_an_G20_3500k_framestats.txt data/bbb_an_G20_1500k_framestats.txt data/bbb_an_G20_2500k_framestats.txt data/bbb_an_G20_3500k_framestats.txt data/ed_an_G20_1500k_framestats.txt data/ed_an_G20_2500k_framestats.txt data/ed_an_G20_3500k_framestats.txt

# Make gop_log.txt for controlled videos
#./gop_log.py data/sintel_an_G20_1500k_framestats.txt data/sintel_an_G20_2500k_framestats.txt data/sintel_an_G20_3500k_framestats.txt data/bbb_an_G20_1500k_framestats.txt data/bbb_an_G20_2500k_framestats.txt data/bbb_an_G20_3500k_framestats.txt data/ed_an_G20_1500k_framestats.txt data/ed_an_G20_2500k_framestats.txt data/ed_an_G20_3500k_framestats.txt

######################################







####### NOOO! GOP vs file size for controlled videos #####

## Make gopstats for original videos without audio track (Takes a long time!)
#./gopstats.sh vids/sintel_an_G20_1500k.avi data/sintel_an_G20_1500k_gopstats.txt
#./gopstats.sh vids/sintel_an_G20_2500k.avi data/sintel_an_G20_2500k_gopstats.txt
#./gopstats.sh vids/sintel_an_G20_3500k.avi data/sintel_an_G20_3500k_gopstats.txt
#./gopstats.sh vids/bbb_an_G20_1500k.avi data/bbb_an_G20_1500k_gopstats.txt
#./gopstats.sh vids/bbb_an_G20_2500k.avi data/bbb_an_G20_2500k_gopstats.txt
#./gopstats.sh vids/bbb_an_G20_3500k.avi data/bbb_an_G20_3500k_gopstats.txt
#./gopstats.sh vids/ed_an_G20_1500k.avi data/ed_an_G20_1500k_gopstats.txt
#./gopstats.sh vids/ed_an_G20_2500k.avi data/ed_an_G20_2500k_gopstats.txt
#./gopstats.sh vids/ed_an_G20_3500k.avi data/ed_an_G20_3500k_gopstats.txt

## Make plot 1 based on originals_gopstat logs
#./gop_vs_fsize.py data/sintel_an_G20_1500k_gopstats.txt data/sintel_an_G20_2500k_gopstats.txt data/sintel_an_G20_3500k_gopstats.txt data/bbb_an_G20_1500k_gopstats.txt data/bbb_an_G20_2500k_gopstats.txt data/bbb_an_G20_3500k_gopstats.txt data/ed_an_G20_1500k_gopstats.txt data/ed_an_G20_2500k_gopstats.txt data/ed_an_G20_3500k_gopstats.txt

####################################################



























##### Save statistics to log #####

# Make frame_log.txt for estimator evalutation
#./frame_log.py data/sintel_an_G20_1500k_framestats.txt data/sintel_an_G20_2500k_framestats.txt data/sintel_an_G20_3500k_framestats.txt data/bbb_an_G20_1500k_framestats.txt data/bbb_an_G20_2500k_framestats.txt data/bbb_an_G20_3500k_framestats.txt data/ed_an_G20_1500k_framestats.txt data/ed_an_G20_2500k_framestats.txt data/ed_an_G20_3500k_framestats.txt

# Make gop_log.txt for estimator evaluation
#./gop_log.py data/sintel_an_G20_1500k_framestats.txt data/sintel_an_G20_2500k_framestats.txt data/sintel_an_G20_3500k_framestats.txt data/bbb_an_G20_1500k_framestats.txt data/bbb_an_G20_2500k_framestats.txt data/bbb_an_G20_3500k_framestats.txt data/ed_an_G20_1500k_framestats.txt data/ed_an_G20_2500k_framestats.txt data/ed_an_G20_3500k_framestats.txt

# Make estimator plot
#./estimators.py data/frame_log.txt data/gop_log.txt

###############################








########## Plot 2 #############

## Make plot 2( 9 plots total)
#./dist_frames.py data/sintel_an_G20_1500k_framestats.txt data/sintel_an_G20_2500k_framestats.txt data/sintel_an_G20_3500k_framestats.txt data/bbb_an_G20_1500k_framestats.txt data/bbb_an_G20_2500k_framestats.txt data/bbb_an_G20_3500k_framestats.txt data/ed_an_G20_1500k_framestats.txt data/ed_an_G20_2500k_framestats.txt data/ed_an_G20_3500k_framestats.txt

##############################






########## Plot 3 #############

## Make plot 3(9 plots total)
#./dist_gop.py data/sintel_an_G20_1500k_framestats.txt data/sintel_an_G20_2500k_framestats.txt data/sintel_an_G20_3500k_framestats.txt data/bbb_an_G20_1500k_framestats.txt data/bbb_an_G20_2500k_framestats.txt data/bbb_an_G20_3500k_framestats.txt data/ed_an_G20_1500k_framestats.txt data/ed_an_G20_2500k_framestats.txt data/ed_an_G20_3500k_framestats.txt

##############################











